package stream;

import pojo.Student;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class PartitioningByStream {
    public static void main(String[] args) {
        Stream<Student> stream = Stream.of(
                new Student("101", "猪八戒", 80),
                new Student("102", "小白龙", 80),
                new Student("103", "猪八戒", 80),
                new Student("104", "小白龙", 100),
                new Student("105", "猪八戒", 100)
        );
//        Map<Boolean, List<Student>> map = stream.collect(Collectors.groupingBy(s -> {
//            return s.getAge() > 80;
//        }));
//        map.forEach((k,v)-> System.out.println(k+"---" + v));

        //把集合分割为两个列，一个true列，一个false列
        Map<Boolean, List<Student>> map2 = stream.collect(Collectors.partitioningBy(s -> s.getAge() > 80));
        map2.forEach((k,v)-> System.out.println(k+"---" + v));
    }
}
